#include "sceneobj.h"
#include "scenenode.h"
#include "renderop.h"
#include "renderqueue.h"
#include "mesh.h"

namespace ZH
{
	SceneObj::SceneObj(const std::string& name)
		: m_Name(name),
		m_pParent(NULL),
		m_pMesh(NULL)
	{
		
	}

	SceneObj::~SceneObj()
	{
		DetachNode();
	}

	void SceneObj::DetachNode()
	{
		if (m_pParent)
		{
			m_pParent->RemoveObj(this);
			m_pParent = NULL;
		}
	}

	void SceneObj::UpdateRenderQueue(RenderQueue& que)
	{
		if (m_pMesh)
		{
 			RenderOp op;
 			op.mesh = m_pMesh;
			op.pass	= &m_Pass;
			op.node	= m_pParent;
			op.obj	= this;
			que.PushRenderOp(op);
		}
	}
}	// end of namespace ZH
